ci(apm): preload PoC basic testing improvements#2554
Conversation
|
|
||
| info!("Writing custom preload agent type definition"); | ||
| let custom_agent_type_path = format!("{DYNAMIC_AGENT_TYPES_DIR}/preload.yaml"); | ||
| let custom_agent_type = r#"namespace: newrelic |
There was a problem hiding this comment.
Claude found this issue:
🔴 Bug: ${{ ... }} won't be substituted by Agent Control
test/e2e-runner/src/linux/scenarios/preload_agent.rs:50-77 — the YAML is a plain r#"..."# raw string, not a format! template, so the doubled braces are not escapes — they end up literally in the file:
repository: ${{nr-var:oci.repository}}
version: ${{nr-var:version}}
Compare with agent-control/tests/on_host/scenarios/oci_auth.rs:43-54, where ${{...}} is inside format!(...) and correctly resolves to ${...}. AC's template engine expects the single-brace form
(${nr-var:version}), so the inlined agent type will fail to resolve version and the OCI download won't get a valid tag.
Fix: use single braces (${nr-var:...}) since this is a raw string, or wrap the literal in format! if you want to keep the doubled form for visual consistency with the other tests.
| let find_so_command = format!(r#"find {package_dir} -type f -name "*.so" | head -n 1"#); | ||
| let so_path = exec_bash_command(&find_so_command) | ||
| .unwrap_or_else(|err| panic!("Failed to find shared library in package: {err}")); | ||
| let so_path = so_path.lines().last().unwrap_or("").trim().to_string(); |
There was a problem hiding this comment.
Also from Claude;
🔴 Bug: so_path extraction picks up the wrapper text, not the actual path
test/e2e-runner/src/linux/scenarios/preload_agent.rs:115-122:
let so_path = exec_bash_command(&find_so_command)...;
let so_path = so_path.lines().last().unwrap_or("").trim().to_string();
exec_bash_command (test/e2e-runner/src/linux/bash.rs:22) does not return raw stdout — it returns a wrapped, multi-line string:
command
success
Stdout:
Stderr:
The Stderr: line is always last, so so_path ends up as "Stderr:" (or empty after the colon depending on trim). The if so_path.is_empty() guard does not catch this, and the next step appends Stderr: to
/etc/ld.so.preload. None of the existing callers parse stdout from exec_bash_command — this is the first one, and it doesn't work.
Fix options (pick one):
- Add a sibling helper that returns just stdout (e.g., exec_bash_command_stdout), then use it here.
- Run find ... -print -quit on the host and have the helper write its result to a file you read_to_string.
- Parse the wrapper: extract the line starting with Stdout: and strip the prefix — least preferred since it bakes in a fragile dependency on the wrapper format.
Summary
This PR builds on top of #2517 and proposes a few improvements to the preload agent E2E scenario, while keeping the changes scoped to a PoC for APM support on-host through the preload library.
Why not commit the agent type definition
The original branch added
agent-control/agent-type-registry/newrelic/com.newrelic.preload-0.1.0.yamlto the main codebase. Since this work is still a PoC, we shouldn't be shipping acom.newrelic.preloadagent type as part of the registry yet. Instead, this PR:agent-type-registry/./etc/newrelic-agent-control/dynamic-agent-types/preload.yaml).This way, the PoC scenario can exercise the full flow (Agent Control loading a custom agent type, downloading the OCI artifact, etc.) without leaking PoC artifacts into the distributed registry.
Test scenario improvements
A few minor assertions were added to the
PreloadAgentscenario so that failures are caught early and surface clear errors instead of failing later in opaque ways while the actual test scenario takes shape:stored_packages/preload-agentdirectory..so) inside the extracted package and fail loudly if none is found..sopath to/etc/ld.so.preload(previously the path was a placeholder and the file path itself was wrong:/ec/ld.so.preload).The local agent config sent to AC was also trimmed to the minimum needed for this PoC (just
version), since the previous fields were not consumed by the agent type used here.CI changes
The
component_onhost_e2e.yamlworkflow was updated so the new scenario actually runs:preload-agentto the scenarios matrix.HOST_E2E_PRELOAD_VERSIONand threaded it through as--preload-versionto the e2e runner.